package com.smooware.icms.fragment.wo;

import android.os.Bundle;
import android.support.v4.app.ActionBar;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;

import com.smooware.icms.R;
import com.smooware.icms.app.WorkOrderActivity;
import com.smooware.icms.fragment.navigation.WOFragmentNavigator;

public class WODashboardFragment extends Fragment {

	protected static final String TAG = WODashboardFragment.class
			.getSimpleName();

	private WOFragmentNavigator fragmentNavigator;

	private ActionBar actionBar;

	public WODashboardFragment() {
	}

	@Override
	public View onCreateView(final LayoutInflater inflater,
			final ViewGroup container, final Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.wo_dashboard_fragment, container,
				false);

		view.findViewById(R.id.dashboard_button_schedule).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(final View v) {
						Log.d(TAG, "dashboard button shedules");
						fragmentNavigator.goToWOSheduleFragment();
					}
				});

		return view;
	}

	@Override
	public void onActivityCreated(final Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);

		fragmentNavigator = ((WorkOrderActivity) getSupportActivity())
				.getFragmentNavigator();

		actionBar = getSupportActivity().getSupportActionBar();

		initActionBar();
	}

	private void initActionBar() {
		if (actionBar.getTabCount() > 0) {
			actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);

			actionBar.removeAllTabs();
		}
	}
}
